using System;
using SoftwareMonkeys.LiveShift.Entities;
using SoftwareMonkeys.LiveShift.Diagnostics;

namespace SoftwareMonkeys.LiveShift.Business
{
	[Serializable]
	public class PopulationGrowBehavior : BaseBehavior
	{
		public Population Population;
		
		public PopulationGrowBehavior (Population population) : base(population)
		{
			Population = population;
		}
		
		public override SoftwareMonkeys.LiveShift.Entities.IShiftResult Shift (DateTime date)
		{
			return Grow(date);
		}
		
		public IShiftResult Grow(DateTime time)
		{
			IShiftResult result = new ShiftResult();
			using (LogGroup logGroup = LogGroup.Start("Population is growing.", NLog.LogLevel.Debug))
			{
				double totalSeconds = time.Subtract(Population.LastShift).TotalSeconds;
				
				
				
				double newPeopleCount = PopulationCalculator.CalculateGrowth(Population.TotalPeople, totalSeconds);
				
				Population.TotalPeople = Population.TotalPeople +
					newPeopleCount;
			}
			return null;
		}
	}
}

